package com.youhome.service.impl;

import com.youhome.mapper.HouseMapper;
import com.youhome.model.House;
import com.youhome.service.HouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * Created by chen365 on 2018/09/17.
 */
@Service
public class HouseServiceImpl implements HouseService {
    @Autowired
    private HouseMapper houseMapper;

    @Override
    public int deleteByPrimaryKey(String houseId) {
        return houseMapper.deleteByPrimaryKey(houseId);
    }

    @Override
    public int insert(House record) {
        record.setCreateTime(new Date());
        return houseMapper.insert(record);
    }

    @Override
    public int insertSelective(House record) {
        record.setCreateTime(new Date());
        return insertSelective(record);
    }

    @Override
    public House selectByPrimaryKey(String houseId) {
        return houseMapper.selectByPrimaryKey(houseId);
    }

    @Override
    public int updateByPrimaryKeySelective(House record) {
        record.setUpdateTime(new Date());
        return houseMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKeyWithBLOBs(House record) {
        record.setUpdateTime(new Date());
        return houseMapper.updateByPrimaryKeyWithBLOBs(record);
    }

    @Override
    public int updateByPrimaryKey(House record) {
        record.setUpdateTime(new Date());
        return houseMapper.updateByPrimaryKey(record);
    }

    @Override
    public boolean selectExistsByPrimaryKey(String houseId) {
        if (houseMapper.selectExistsByPrimaryKey(houseId) > 0) {
            return true;
        }
        return false;
    }
}
